<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/6/23
 * Time: 15:13
 * Project name: PHPTEST
 * File name: 3.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

$init = curl_init("wp.dev");
curl_setopt($init,CURLOPT_RETURNTRANSFER,true);
$html = curl_exec($init);
preg_match( '/<title>(.*)<\/title>/siU', $html, $title_matches );
print_r($title_matches);
echo PHP_EOL;
$subject = preg_replace( '/\s+/', ' ', $title_matches[1] );
print_r($subject);
echo PHP_EOL;
$subject = trim( $subject );
print_r($subject);
$subject = preg_replace_callback("/(&#[0-9]+;)/", 'wpm_convertstring', $subject);
function wpm_convertstring( $m ) {
	return mb_convert_encoding( $m[1], "UTF-8", "HTML-ENTITIES" );
}

preg_match( '/<style[^>]*>(.*)<\/style>/smiU', $html, $css_matches );
if ( $css_matches[1] ) {
	$css = $css_matches[1];
	print_r($css);
}

